/*
struct TreeNode {
    int val;
    struct TreeNode *left;
    struct TreeNode *right;
    TreeNode(int x) :
            val(x), left(NULL), right(NULL) {
    }
};
*/
class Solution {
public:
    bool isSymmetrical(TreeNode* p) {
        if(!p) return true;
        return Judge(p->left, p->right);
    }
    bool Judge(TreeNode* p1, TreeNode* p2) {
        if(!p1 && !p2) return true;
        if(p1 && p2) {
            return p1->val == p2->val && Judge(p1->left, p2->right) && Judge(p1->right, p2->left);
        }
        return false;
    }

};